﻿-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<后台操作日志列表>
-- =============================================
CREATE PROCEDURE [dbo].[proc_ZHSZLog_GetList]
(
	@StartIndex int,
	@EndIndex INT,
	@Stext NVARCHAR(200),
	@StartDate NVARCHAR(10),
	@EndDate NVARCHAR(10)
)
AS
BEGIN
	
	Declare @sRq Datetime,@eRq Datetime
	Set @sRq = Convert(Datetime,@StartDate+' 00:00:00')
	Set @eRq = Convert(Datetime,@EndDate+' 23:59:59')
	
	;WITH List As(Select ROW_NUMBER() OVER (Order BY czrq Desc) AS Row,
		id, 
		userid, 
		username, 
		cznr,
		czrid, 
		czrname, 
		czrIP, 
		czrq
	    FROM [ZHSZLog]
	    WHERE 
	    (
	    userid = @Stext
	    OR username=@Stext
	    OR czrid=@Stext
	    OR czrname=@Stext
	    --OR czrIP=@Stext
	    --OR cznr LIKE '''%'+@Stext+'%'''
	    OR @Stext=''
	    )
		AND czrq>=@sRq And czrq<=@eRq
	)
	Select *,(Select Count(0) From list) As RecordCount From list Where Row Between @StartIndex and @EndIndex Order By Row
END
